//
// Created by Strawberry on 2022/4/12.
//

#include "Page.h"

Page::Page(int frameNumber, bool isInMemory, long long int logicalLoc, int accessFlag)
    : frame_number(frameNumber), is_in_memory(isInMemory), logical_loc(logicalLoc),
      access_flag(accessFlag)
{
    this->page_number = get_page_number(logicalLoc);
}

//TESTED
int Page::get_page_number(long long int logical_loc)
{
    return logical_loc >> g_offset_n;
}

std::ostream &operator<<(std::ostream &os, const Page &page)
{
    os << "[frame_number: " << page.frame_number << ",page_number: " << page.page_number << ",is_in_memory: "
       << page.is_in_memory << ",logical_loc: " << page.logical_loc << ",access_flag: " << page.access_flag << "]";
    return os;
}

Page::Page() {}
